package com.jingbit.dialog;

import android.content.Context;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;

public class DynamicPublishDialog extends CustomBaseDialog {
    private Button btnVideo;
    private Button btnPhoto;
    private Button btnCancel;

    private IClickListener clickListener;//取消按钮被点击了的监听器

    public DynamicPublishDialog(Context context) {
        super(context, R.style.CustomDialog);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_dynamic);
        //初始化界面控件
        btnVideo = findViewById(R.id.btn_video);
        btnPhoto = findViewById(R.id.btn_photo);
        btnCancel = findViewById(R.id.btn_cancel);

        //设置确定按钮被点击后，向外界提供监听
        btnVideo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                if (clickListener != null) {
                    clickListener.onVideo();
                }
            }
        });

        //设置取消按钮被点击后，向外界提供监听
        btnPhoto.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                if (clickListener != null) {
                    clickListener.onPhoto();
                }
            }
        });

        btnCancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
    }

    public void show(IClickListener clickListener) {
        this.clickListener = clickListener;
        showDialog(Gravity.BOTTOM, R.style.AnimBottom, 1, 0);
    }

    public interface IClickListener {
        public void onVideo();

        public void onPhoto();
    }

}